<!doctype html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<meta name="viewport" content="width=device-width, initial-scale=1.0">
	<link rel="stylesheet" href="./../assets/css/combined.css">
	<link rel="shortcut icon" href="./../favicon.ico" />
	<script src="http://www.google.com/jsapi" type="text/javascript"></script>
	<script type="text/javascript">
		var path = './../';
		var class_prefix = "Form::";
	</script>
	<script src="./../assets/js/combined.js"></script>
	<title>Form - Classes - FuelPHP Documentation</title>
</head>
<body>
	<div id="container">
		<header id="header">
			<div class="table">
				<h1>
					<strong>FuelPHP, a PHP 5.3 Framework</strong>
					Documentation
				</h1>

				<form id="google_search">
					<p>
						<span id="search_clear">&nbsp;</span>
						<input type="submit" name="search_submit" id="search_submit" value="search" />
						<input type="text" value="" id="search_input" name="search_input" />
					</p>
				</form>
			</div>
			<nav>

				<div class="clear"></div>
			</nav>
			<a href="#" id="toc_handle">table of contents</a>
			<div class="clear"></div>
		</header>

		<div id="cse">
			<div id="cse_point"></div>
			<div id="cse_content"></div>
		</div>

		<div id="main">

			<h2>Form Class</h2>

			<p>
				The Form class can both be used to create individual form elements or to create a full form along with
				validation, the latter is done in combination with the <a href="fieldset/fieldset.html">Fieldset</a> class.
			</p>

			<h3 id="creatin_elements">Create individual form elements</h3>

			<article>
				<h4 class="method" id="method_open">open($attributes = array(), $hidden = array())</h4>
				<p>Create a form open tag.</p>
				<table class="method">
					<tbody>
					<tr>
						<th class="legend">Static</th>
						<td>Yes</td>
					</tr>
					<tr>
						<th>Parameters</th>
						<td>
							<table class="parameters">
								<tr>
									<th>Param</th>
									<th>Default</th>
									<th class="description">Description</th>
								</tr>
								<tr>
									<th><kbd>$attributes</kbd></th>
									<td><pre class="php"><code>array()</code></pre></td>
									<td>Either a string which will be the action attribute or an array of settings, if
										action isn't given it will use the current Uri. The attribute's values will be used
										as html tag properties.</td>
								</tr>
								<tr>
									<th><kbd>$hidden</kbd></th>
									<td><pre class="php"><code>array()</code></pre></td>
									<td>An associative array of fieldnames and their values, will all be set as hidden
										fields.</td>
								</tr>
							</table>
						</td>
					</tr>
					<tr>
						<th>Returns</th>
						<td>string</td>
					</tr>
					<tr>
						<th>Example</th>
						<td>
							<pre class="php"><code>// returns &lt;form action="http://mydomain.com/uri/to/form" accept-charset="utf-8" method="post"&gt;
echo Form::open('uri/to/form');

// returns &lt;form action="http://google.com/" accept-charset="utf-8" method="get"&gt;
echo Form::open(array('action' => 'http://google.com/', 'method' => 'get'));</code></pre>
						</td>
					</tr>
					</tbody>
				</table>
			</article>

			<article>
				<h4 class="method" id="method_close">close()</h4>
				<p>Create a form close tag.</p>
				<table class="method">
					<tbody>
					<tr>
						<th class="legend">Static</th>
						<td>Yes</td>
					</tr>
					<tr>
						<th>Parameters</th>
						<td>(none)</td>
					</tr>
					<tr>
						<th>Returns</th>
						<td>string</td>
					</tr>
					<tr>
						<th>Example</th>
						<td>
							<pre class="php"><code>// returns &lt;/form&gt;
echo Form::close();</code></pre>
						</td>
					</tr>
					</tbody>
				</table>
			</article>

			<article>
				<h4 class="method" id="method_input">input($field, $value = null, $attributes = array())</h4>
				<p>
					Creates an html input element. It can be set using the fieldname, its value and tag attributes or all
					in one array as the first argument.
				</p>
				<table class="method">
					<tbody>
					<tr>
						<th class="legend">Static</th>
						<td>Yes</td>
					</tr>
					<tr>
						<th>Parameters</th>
						<td>
							<table class="parameters">
								<tr>
									<th>Param</th>
									<th>Default</th>
									<th class="description">Description</th>
								</tr>
								<tr>
									<th><kbd>$field</kbd></th>
									<td><i>Required</i></td>
									<td>Either a string for the fieldname or an array of tag attributes.</td>
								</tr>
								<tr>
									<th><kbd>$value</kbd></th>
									<td><pre class="php"><code>null</code></pre></td>
									<td>Field value, will be ignored when the first param is an array.</td>
								</tr>
								<tr>
									<th><kbd>$attributes</kbd></th>
									<td><pre class="php"><code>array()</code></pre></td>
									<td>These will be used as html tag properties.</td>
								</tr>
							</table>
						</td>
					</tr>
					<tr>
						<th>Returns</th>
						<td>string</td>
					</tr>
					<tr>
						<th>Example</th>
						<td>
							<pre class="php"><code>echo Form::input('name', 'value', array('style' => 'border: 2px;'));
// more to be added</code></pre>
						</td>
					</tr>
					</tbody>
				</table>
			</article>

			<article>
				<h4 class="method" id="method_button">button($field, $value = null, $attributes = array())</h4>
				<p>
					Creates an html button element. It can be set using the fieldname, its value and tag attributes or all
					in one array as the first argument.
				</p>
				<table class="method">
					<tbody>
					<tr>
						<th class="legend">Static</th>
						<td>Yes</td>
					</tr>
					<tr>
						<th>Parameters</th>
						<td>
							<table class="parameters">
								<tr>
									<th>Param</th>
									<th>Default</th>
									<th class="description">Description</th>
								</tr>
								<tr>
									<th><kbd>$field</kbd></th>
									<td><i>Required</i></td>
									<td>Either a string for the fieldname or an array of tag attributes.</td>
								</tr>
								<tr>
									<th><kbd>$value</kbd></th>
									<td><pre class="php"><code>null</code></pre></td>
									<td>Field value, will be ignored when the first param is an array.</td>
								</tr>
								<tr>
									<th><kbd>$attributes</kbd></th>
									<td><pre class="php"><code>array()</code></pre></td>
									<td>These will be used as html tag properties.</td>
								</tr>
							</table>
						</td>
					</tr>
					<tr>
						<th>Returns</th>
						<td>string</td>
					</tr>
					<tr>
						<th>Example</th>
						<td>
							<pre class="php"><code>echo Form::button('name', 'value', array('style' => 'border: 2px;'));</code></pre>
						</td>
					</tr>
					</tbody>
				</table>
			</article>

			<article>
				<h4 class="method" id="method_hidden">hidden($field, $value = null, $attributes = array())</h4>

				<p>This is an alias for <kbd>Form::input()</kbd> that automatically sets the <kbd>type</kbd> attribute to
				<kbd>'hidden'</kbd>.</p>
			</article>

			<article>
				<h4 class="method" id="method_csrf">csrf()</h4>

				<p>Creates an html input element with the <kbd>value</kbd> attribute automatically set to the generated CSRF token.</p>
			</article>

			<article>
				<h4 class="method" id="method_password">password($field, $value = null, $attributes = array())</h4>

				<p>This is an alias for <kbd>Form::input()</kbd> that automatically sets the <kbd>type</kbd> attribute to
				<kbd>'password'</kbd>.</p>
			</article>

			<article>
				<h4 class="method" id="method_radio">radio($field, $value = null, $attributes = array())</h4>

				<p>This is an alias for <kbd>Form::input()</kbd> that automatically sets the <kbd>type</kbd> attribute to
				<kbd>'radio'</kbd>.<br />
				<em>For backwards compatibility this method also accepts: <kbd>checkbox($field, $value = null, array $attributes = array())</kbd></em></p>
				<table class="method">
					<tbody>
					<tr>
						<th class="legend">Static</th>
						<td>Yes</td>
					</tr>
					<tr>
						<th>Parameters</th>
						<td>
							<table class="parameters">
								<tr>
									<th>Param</th>
									<th>Default</th>
									<th class="description">Description</th>
								</tr>
								<tr>
									<th><kbd>$field</kbd></th>
									<td><i>Required</i></td>
									<td>Either a string for the fieldname or an array of tag attributes.</td>
								</tr>
								<tr>
									<th><kbd>$value</kbd></th>
									<td><pre class="php"><code>null</code></pre></td>
									<td>Field value, will be ignored when the first param is an array.</td>
								</tr>
								<tr>
									<th><kbd>$checked</kbd></th>
									<td><pre class="php"><code>null</code></pre></td>
									<td>Whether checked (if bool) or matches $value (if string), will be ignored when
										the first param is an array.</td>
								</tr>
								<tr>
									<th><kbd>$attributes</kbd></th>
									<td><pre class="php"><code>array()</code></pre></td>
									<td>These will be used as html tag properties.</td>
								</tr>
							</table>
						</td>
					</tr>
					<tr>
						<th>Returns</th>
						<td>string</td>
					</tr>
					<tr>
						<th>Example</th>
						<td>
							<pre class="php"><code>echo Form::label('Male', 'gender');
echo Form::radio('gender', 'Male', true);
echo Form::label('Female', 'gender');
echo Form::radio('gender', 'Female');</code></pre>
						</td>
					</tr>
					</tbody>
				</table>

			</article>

			<article>
				<h4 class="method" id="method_checkbox">checkbox($field, $value = null, $checked = null, $attributes = array())</h4>

				<p>This is an alias for <kbd>Form::input()</kbd> that automatically sets the <kbd>type</kbd> attribute to
				<kbd>'checkbox'</kbd>.<br />
				<em>For backwards compatibility this method also accepts: <kbd>checkbox($field, $value = null, array $attributes = array())</kbd></em></p>
<table class="method">
					<tbody>
					<tr>
						<th class="legend">Static</th>
						<td>Yes</td>
					</tr>
					<tr>
						<th>Parameters</th>
						<td>
							<table class="parameters">
								<tr>
									<th>Param</th>
									<th>Default</th>
									<th class="description">Description</th>
								</tr>
								<tr>
									<th><kbd>$field</kbd></th>
									<td><i>Required</i></td>
									<td>Either a string for the fieldname or an array of tag attributes.</td>
								</tr>
								<tr>
									<th><kbd>$value</kbd></th>
									<td><pre class="php"><code>null</code></pre></td>
									<td>Field value, will be ignored when the first param is an array.</td>
								</tr>
								<tr>
									<th><kbd>$checked</kbd></th>
									<td><pre class="php"><code>null</code></pre></td>
									<td>Whether checked (if bool) or matches $value (if string), will be ignored when
										the first param is an array.</td>
								</tr>
								<tr>
									<th><kbd>$attributes</kbd></th>
									<td><pre class="php"><code>array()</code></pre></td>
									<td>These will be used as html tag properties.</td>
								</tr>
							</table>
						</td>
					</tr>
					<tr>
						<th>Returns</th>
						<td>string</td>
					</tr>
					<tr>
						<th>Example</th>
						<td>
							<pre class="php"><code>echo Form::label('Male', 'gender');
echo Form::checkbox('gender', 'Male', true);
echo Form::label('Female', 'gender');
echo Form::checkbox('gender', 'Female');</code></pre>
						</td>
					</tr>
					</tbody>
				</table>
			</article>

			<article>
				<h4 class="method" id="method_file">file($field, $attributes = array())</h4>

				<p>This is an alias for <kbd>Form::input()</kbd> that automatically sets the <kbd>type</kbd> attribute to
				<kbd>'file'</kbd>.</p>
			</article>

			<article>
				<h4 class="method" id="method_reset">reset($field, $value = null, $attributes = array())</h4>

				<p>This is an alias for <kbd>Form::input()</kbd> that automatically sets the <kbd>type</kbd> attribute to
				<kbd>'reset'</kbd>.</p>
			</article>

			<article>
				<h4 class="method" id="method_submit">submit($field, $value = null, $attributes = array())</h4>

				<p>This is an alias for <kbd>Form::input()</kbd> that automatically sets the <kbd>type</kbd> attribute to
				<kbd>'submit'</kbd>.</p>
			</article>

			<article>
				<h4 class="method" id="method_textarea">textarea($field, $value = null, $attributes = array())</h4>
				<p>Creates an html textarea element. It can be set using the fieldname, its value and tag attributes or all
					in one attribute for the first argument.</p>
				<table class="method">
					<tbody>
					<tr>
						<th class="legend">Static</th>
						<td>Yes</td>
					</tr>
					<tr>
						<th>Parameters</th>
						<td>
							<table class="parameters">
								<tr>
									<th>Param</th>
									<th>Default</th>
									<th class="description">Description</th>
								</tr>
								<tr>
									<th><kbd>$field</kbd></th>
									<td><i>Required</i></td>
									<td>Either a string for the fieldname or an array of tag attributes.</td>
								</tr>
								<tr>
									<th><kbd>$value</kbd></th>
									<td><pre class="php"><code>null</code></pre></td>
									<td>Field value, will be ignored when the first param is an array.</td>
								</tr>
								<tr>
									<th><kbd>$attributes</kbd></th>
									<td><pre class="php"><code>array()</code></pre></td>
									<td>These will be used as html tag properties.</td>
								</tr>
							</table>
						</td>
					</tr>
					<tr>
						<th>Returns</th>
						<td>string</td>
					</tr>
					<tr>
						<th>Example</th>
						<td>
							<pre class="php"><code>echo Form::textarea('description', 'enter here', array('rows' => 6, 'cols' => 8));
// more to be added</code></pre>
						</td>
					</tr>
					</tbody>
				</table>
			</article>

			<article>
				<h4 class="method" id="method_select">select($field, $values = null, $options = array(), $attributes = array())</h4>
				<p>Creates an html select element. It can be set using the fieldname, its selected value(s), its options
					and tag attributes or all in one attribute for the first argument.</p>
				<table class="method">
					<tbody>
					<tr>
						<th class="legend">Static</th>
						<td>Yes</td>
					</tr>
					<tr>
						<th>Parameters</th>
						<td>
							<table class="parameters">
								<tr>
									<th>Param</th>
									<th>Default</th>
									<th class="description">Description</th>
								</tr>
								<tr>
									<th><kbd>$field</kbd></th>
									<td><i>Required</i></td>
									<td>Either a string for the fieldname or an array of tag attributes.</td>
								</tr>
								<tr>
									<th><kbd>$values</kbd></th>
									<td><pre class="php"><code>null</code></pre></td>
									<td>Selected value or array of values for multiselect, will be ignored when the first
										param is an array.</td>
								</tr>
								<tr>
									<th><kbd>$options</kbd></th>
									<td><pre class="php"><code>array()</code></pre></td>
									<td>Associative array of value=>label pairs, may also contain option groups as
										opt_name=>array() where the array contains its set of value=>label pairs.</td>
								</tr>
								<tr>
									<th><kbd>$attributes</kbd></th>
									<td><pre class="php"><code>array()</code></pre></td>
									<td>These will be used as html tag properties.</td>
								</tr>
							</table>
						</td>
					</tr>
					<tr>
						<th>Returns</th>
						<td>string</td>
					</tr>
					<tr>
						<th>Example</th>
						<td>
							<pre class="php"><code>echo Form::select('country', 'none', array(
	'none' => 'None',
	'europe' => array(
		'uk' => 'United Kingdom',
		'nl' => 'Netherlands'
	),
	'us' => 'United States'
));
// more to be added</code></pre>
						</td>
					</tr>
					</tbody>
				</table>
			</article>

			<article>
				<h4 class="method" id="method_label">label($label, $id = null, $attributes = array())</h4>
				<p>Creates an html label element. It can be set using label, the id it's for and tag attributes or all
					in one attribute for the first argument.</p>
				<table class="method">
					<tbody>
					<tr>
						<th class="legend">Static</th>
						<td>Yes</td>
					</tr>
					<tr>
						<th>Parameters</th>
						<td>
							<table class="parameters">
								<tr>
									<th>Param</th>
									<th>Default</th>
									<th class="description">Description</th>
								</tr>
								<tr>
									<th><kbd>$label</kbd></th>
									<td><i>Required</i></td>
									<td>Either a string for the label or an array of tag attributes.</td>
								</tr>
								<tr>
									<th><kbd>$id</kbd></th>
									<td><pre class="php"><code>null</code></pre></td>
									<td>The field's id this label belongs to.</td>
								</tr>
								<tr>
									<th><kbd>$attributes</kbd></th>
									<td><pre class="php"><code>array()</code></pre></td>
									<td>These will be used as html tag properties.</td>
								</tr>
							</table>
						</td>
					</tr>
					<tr>
						<th>Returns</th>
						<td>string</td>
					</tr>
					<tr>
						<th>Example</th>
						<td>
							<pre class="php"><code>echo Form::label('Username', 'username');
// more to be added</code></pre>
						</td>
					</tr>
					</tbody>
				</table>
			</article>

			<article>
				<h4 class="method" id="method_fieldset_open">fieldset_open($attributes = array(), $legend = null)</h4>
				<p>Create a fieldset open tag.</p>
				<table class="method">
					<tbody>
					<tr>
						<th class="legend">Static</th>
						<td>Yes</td>
					</tr>
					<tr>
						<th>Parameters</th>
						<td>
							<table class="parameters">
								<tr>
									<th>Param</th>
									<th>Default</th>
									<th class="description">Description</th>
								</tr>
								<tr>
									<th><kbd>$attributes</kbd></th>
									<td><pre class="php"><code>array()</code></pre></td>
									<td>An array of settings; may use the key of 'legend' to set the fieldset's legend attribute.
									The attribute's values will be used as html tag properties.</td>
								</tr>
								<tr>
									<th><kbd>$legend</kbd></th>
									<td><pre class="php"><code>string</code></pre></td>
									<td>String to be used for the legend fieldset option</td>
								</tr>
							</table>
						</td>
					</tr>
					<tr>
						<th>Returns</th>
						<td>string</td>
					</tr>
					<tr>
						<th>Example</th>
						<td>
							<pre class="php"><code>// returns &lt;fieldset &gt;
echo Form::fieldset_open();

// returns &lt;fieldset class="example-class" id="example-id"&gt;
echo Form::fieldset_open(array('class' => 'example-class', 'id' => 'example-id'));

// returns &lt;fieldset class="example-class" id="example-id"&gt;&lt;legend&gt;Custom Legend&lt;/legend&gt;
echo Form::fieldset_open(array('class' => 'example-class', 'id' => 'example-id'), 'Custom Legend');

// returns &lt;fieldset class="example-class" id="example-id"&gt;&lt;legend&gt;Custom Legend&lt;/legend&gt;
echo Form::fieldset_open(array('class' => 'example-class', 'id' => 'example-id', 'legend' => 'Custom Legend'));</code></pre>
						</td>
					</tr>
					</tbody>
				</table>
			</article>

			<article>
				<h4 class="method" id="method_fieldset_close">fieldset_close()</h4>
				<p>Create a fieldset close tag.</p>
				<table class="method">
					<tbody>
					<tr>
						<th class="legend">Static</th>
						<td>Yes</td>
					</tr>
					<tr>
						<th>Parameters</th>
						<td>(none)</td>
					</tr>
					<tr>
						<th>Returns</th>
						<td>string</td>
					</tr>
					<tr>
						<th>Example</th>
						<td>
							<pre class="php"><code>// returns &lt;/fieldset&gt;
echo Form::fieldset_close();</code></pre>
						</td>
					</tr>
					</tbody>
				</table>
			</article>


			<h3 id="create_forms_oop">Create forms in an OOP way using fieldsets</h3>

			<p>See <a href="fieldset/fieldset.html">Fieldset</a></p>

		</div>

		<footer>
			<p>
				&copy; FuelPHP Development Team 2010-2013 - <a href="http://fuelphp.com">FuelPHP</a> is released under the MIT license.
			</p>
		</footer>
	</div>
</body>
</html>
